package es.capgemini.extjsplugin.wizard;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IPackageFragment;

import es.capgemini.extjsplugin.ui.ExtendedField;
/**
 * Clase que sirve de Model para almacenar las opciones sobre la cual se ban a generar los componentes
 * @author Lisandro Medrano
 *
 */
public class GeneratorWizardModel {
	private Class myClass;
	private String package_url="";
	private String package_name="";
	private IPackageFragment packageFragment;
	private List<IProject> projects=new ArrayList<IProject>(); 
	public String getPackage_name() {
		return package_name;
	}
	public void setPackage_name(String packageName) {
		package_name = packageName;
	}
	private String web_folder="";
	private boolean listado=false;
	private boolean editarEliminar=false;
	private boolean altaEdicionForm=false;
	private boolean flow=false;
	private boolean manager=false;
	private boolean dao=false;
	private boolean dto=false;
	
	private List<ExtendedField> camposIncluir;
	
	
	
	public List<ExtendedField> getCamposIncluir() {
		return camposIncluir;
	}
	public void setCamposIncluir(List<ExtendedField> camposIncluir) {
		this.camposIncluir = camposIncluir;
	}
	public Class getMyClass() {
		return myClass;
	}
	public void setMyClass(Class myClass) {
		this.myClass = myClass;
	}
	public String getPackage_url() {
		return package_url;
	}
	public void setPackage_url(String packageUrl) {
		package_url = packageUrl;
	}
	public String getWeb_folder() {
		return web_folder;
	}
	public void setWeb_folder(String webFolder) {
		web_folder = webFolder;
	}
	public boolean isListado() {
		return listado;
	}
	public void setListado(boolean listado) {
		this.listado = listado;
	}
	public boolean isEditarEliminar() {
		return editarEliminar;
	}
	public void setEditarEliminar(boolean editarEliminar) {
		this.editarEliminar = editarEliminar;
	}
	public boolean isAltaEdicionForm() {
		return altaEdicionForm;
	}
	public void setAltaEdicionForm(boolean altaEdicionForm) {
		this.altaEdicionForm = altaEdicionForm;
	}
	public boolean isFlow() {
		return flow;
	}
	public void setFlow(boolean flow) {
		this.flow = flow;
	}
	public boolean isManager() {
		return manager;
	}
	public void setManager(boolean manager) {
		this.manager = manager;
	}
	public boolean isDao() {
		return dao;
	}
	public void setDao(boolean dao) {
		this.dao = dao;
	}
	public boolean isDto() {
		return dto;
	}
	public void setDto(boolean dto) {
		this.dto = dto;
	}
	@Override
	public String toString() {
		
		return "Class:"+myClass.getSimpleName()+
				", package:"+package_url+
				", web: "+web_folder+
				", atributes:"+getAttributes()+
				", dao:"+dao+
				", manager:"+manager+
				", flow:"+flow;
	}
	public List<ExtendedField> getAttributes(){
		List<ExtendedField> fields=new ArrayList<ExtendedField>();
		for(Field f:myClass.getDeclaredFields()){
			fields.add(new ExtendedField(true,f));	
		}
		return fields;
	}
	public IPackageFragment getPackageFragment() {
		return packageFragment;
	}
	public void setPackageFragment(IPackageFragment packageFragment) {
		this.packageFragment = packageFragment;
	}
	public void addProject(IProject project){
		if(!projects.contains(project))
			projects.add(project);
	}
	public List<IProject> getProjects(){
		return projects;
	}
	
	
	
}
